Skip to content

feat: improve version checking#799

Merged
mbevc1 merged 19 commits intomainfrom
20260417_update_check
Apr 20, 2026
Merged

feat: improve version checking#799
mbevc1 merged 19 commits intomainfrom
20260417_update_check

Conversation

@mbevc1
Copy link
Copy Markdown
Contributor

@mbevc1 mbevc1 commented Apr 17, 2026

  • properly handle sync version checking when using --version
  • don't check latest version when using JSON output (avoid polluting outputs in GHA pipelines)
  • add testing for JSON output scenario
  • lower the async timeout to 1 sec (prevent long waits on slower connections)
  • local builds use dev as version
  • disable version check in debug mode

@mbevc1 mbevc1 added enhancement New feature or request go Pull requests that update go code labels Apr 17, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 17, 2026

Claude finished @mbevc1's task in 2m 27s —— View job


PR Review: feat: improve version checking

  • Run static analysis (build, vet, mod tidy)
  • Read changed files
  • Review code quality and correctness
  • Post inline comments and summary

Static Analysis

All checks pass: go build ./..., go vet ./..., go mod tidy — no issues.

Summary

This is a solid, well-structured PR. The changes address real pain points (JSON output pollution in CI, version check on --version, debug mode suppression) and the iteration through review feedback has been productive. Key observations:

What's good:

  • sync.RWMutex-protected override with single-read pattern in CheckForUpdate — cleanly addresses the double-read race. The race stress test locks this in.
  • strconv.ParseBool for KOSLI_DEBUG in innerMain — correctly matches Viper's bool coercion, handling false/0/TRUE properly.
  • Skipping version check for non-table output — practical improvement for CI pipelines, and forward-compatible with future output formats.
  • Test coverage for --version notice path via innerMain with called bool verification — closes the executeCommandC bypass gap.
  • KOSLI_NO_UPDATE_CHECK=1 in the race test — prevents real HTTP calls when the override is momentarily nil.

Minor nits (non-blocking):

  • The --version block in innerMain (lines 52-65) is deeply nested (3 levels). Could be flattened with an early return after determining debugEnabled. Style preference only — see inline comment.

No bugs, no security issues, no missing edge cases. The previous review rounds have been thorough and the feedback has been addressed well. LGTM.

Comment thread internal/version/update_check.go
Comment thread internal/version/update_check.go Outdated
Comment thread cmd/kosli/main.go
Comment thread internal/version/update_check.go Outdated
Comment thread cmd/kosli/root_test.go Outdated
Comment thread internal/version/update_check.go
Comment thread cmd/kosli/main.go
Comment thread internal/version/update_check.go Outdated
Comment thread cmd/kosli/root.go
Comment thread internal/version/update_check.go Outdated
Comment thread cmd/kosli/root.go Outdated
Comment thread cmd/kosli/main.go Outdated
Comment thread internal/version/update_check.go
Comment thread internal/version/update_check_test.go Outdated
Comment thread cmd/kosli/root.go
Comment thread cmd/kosli/root_test.go
Copy link
Copy Markdown
Contributor Author

@mbevc1 mbevc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goroutine-safety nit on SetCheckForUpdateOverride — inline with a sync.RWMutex suggestion and a race test. Current call site is fine by happens-before; the mutex is cheap insurance against future callers / flaky timings.


Generated by Claude Code

Comment thread internal/version/update_check.go
Comment thread cmd/kosli/main.go
Comment thread internal/version/update_check.go
Comment thread internal/version/update_check.go
Comment thread cmd/kosli/root.go Outdated
Copy link
Copy Markdown
Contributor Author

@mbevc1 mbevc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage gap: executeCommandC bypasses innerMain, so the new --version sync-notice branch in main.go has no test coverage. Inline with a sketch calling innerMain directly via the existing SetCheckForUpdateOverride helper.


Generated by Claude Code

Comment thread cmd/kosli/main.go
Comment thread internal/version/update_check.go Outdated
Comment thread internal/version/update_check.go
Comment thread cmd/kosli/root.go Outdated
Comment thread cmd/kosli/root_test.go
Comment thread internal/version/update_check.go Outdated
mbevc1 and others added 19 commits April 20, 2026 17:01
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
future prof machine formatting

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
update the comment as well

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
@mbevc1 mbevc1 force-pushed the 20260417_update_check branch from d37685b to 8ff25e7 Compare April 20, 2026 16:01
Comment thread cmd/kosli/main.go
Comment thread cmd/kosli/main.go
Comment thread internal/version/update_check.go
Comment thread cmd/kosli/root.go
Comment thread cmd/kosli/root_test.go
Comment thread internal/version/update_check_test.go
@mbevc1 mbevc1 merged commit d76c084 into main Apr 20, 2026
29 checks passed
@mbevc1 mbevc1 deleted the 20260417_update_check branch April 20, 2026 21:02
github-actions Bot pushed a commit that referenced this pull request Apr 21, 2026
* feat: improve version checking

* Update internal/version/update_check.go

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* feat: improve version checking - fix tests

* feat: improve version checking - review improvements

* feat: improve version checking - fix testing

* feat: improve version checking - add version test

* feat: improve version checking - fix version test

* chore: Update internal/version/update_check.go

* feat: improve version checking - fix missing import

* chore: Update cmd/kosli/root.go

future prof machine formatting

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* chore: Update cmd/kosli/root.go

update the comment as well

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* feat: improve version checking - add race test

* fix: AI broken suggestion

* feat: improve version checking - improve fragile testing

* feat: improve version checking - remove duplicated and add empty version test

* feat: improve version checking - disable when in debug mode

* fix: Update cmd/kosli/version.go typo

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* chore: Update cmd/kosli/root.go comment

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* feat: improve version checking - parse DEBUG ENV same as Viper

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants